-
Notifications
You must be signed in to change notification settings - Fork 869
feat(shard-distributor): add SpectatorPeerChooser for shard-aware routing #7478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(shard-distributor): add SpectatorPeerChooser for shard-aware routing #7478
Conversation
642ad52 to
1597904
Compare
f4bb653 to
85017c4
Compare
service/sharddistributor/client/spectatorclient/peer_chooser.go
Outdated
Show resolved
Hide resolved
service/sharddistributor/client/spectatorclient/peer_chooser.go
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| // Extract GRPC address from owner metadata | ||
| grpcAddress, ok := owner.Metadata[grpcAddressMetadataKey] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: a bit unexpected to see such specifics as grpcAddressMetadataKey here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would like better separation. We need to address here, so I decided to do it like this, but it does feel like mixing application and network level.
service/sharddistributor/client/spectatorclient/peer_chooser.go
Outdated
Show resolved
Hide resolved
89bb17f to
1e6cc8a
Compare
Implement a YARPC peer chooser that routes requests to the correct
executor based on shard ownership. This is the shard distributor
equivalent of Cadence's RingpopPeerChooser.
Flow:
1. Client calls RPC with yarpc.WithShardKey("shard-key")
2. Chooser queries Spectator for shard owner
3. Extracts grpc_address from owner metadata
4. Creates/reuses peer for that address
5. Returns peer to YARPC for connection
The peer chooser maintains a cache of peers and handles concurrent
access safely. It uses the x-shard-distributor-namespace header to
determine which namespace's spectator to query.
Dependencies:
- Requires spectator GetShardOwner to return metadata (see previous commit)
Signed-off-by: Jakob Haahr Taankvist <[email protected]>
Signed-off-by: Jakob Haahr Taankvist <[email protected]>
The tests have dependency issues with mock generation that need to be resolved separately. The peer chooser implementation is complete and functional. Signed-off-by: Jakob Haahr Taankvist <[email protected]>
Tests cover: - Success path with peer creation - Peer reuse on subsequent calls - Error cases (missing shard key, namespace header, spectator not found) - Lifecycle methods (Start, Stop, IsRunning) - SetSpectators method Signed-off-by: Jakob Haahr Taankvist <[email protected]>
Signed-off-by: Jakob Haahr Taankvist <[email protected]>
Signed-off-by: Jakob Haahr Taankvist <[email protected]>
…peer creation and mutex lock and unlock Signed-off-by: Jakob Haahr Taankvist <[email protected]>
1e6cc8a to
83f485a
Compare
This PR depends on #7476 (spectator return metadata) being merged first.
What changed?
Added
SpectatorPeerChooserthat implements YARPC's peer.Chooser interface to route requests to the correct executor based on shard ownership.Why?
Enable executor-to-executor communication in the shard distributor canary system. The peer chooser queries the Spectator to find which executor owns a shard, then routes requests to that executor's gRPC address.
How did you test it?
Unit tests
Potential risks
None
Release notes
Documentation Changes